package com.yuanzong.wuliu.service.admin.business.customer;

import com.yuanzong.wuliu.common.exception.BusinessException;
import com.yuanzong.wuliu.common.vo.ApiResult;
import com.yuanzong.wuliu.common.vo.ApiResultPage;
import com.yuanzong.wuliu.controller.admin.business.customer.param.AdminBusinessCustomerBaodanPageParam;
import com.yuanzong.wuliu.controller.intercdeptor.AdminHandlerInterceptorAdapter;
import com.yuanzong.wuliu.model.business.customer.BusinessCustomerBaodan;
import com.yuanzong.wuliu.model.business.customer.bo.BusinessCustomerBaodanPageByMapperBo;
import com.yuanzong.wuliu.model.business.customer.query.BusinessCustomerBaodanPageQuery;
import com.yuanzong.wuliu.model.system.user.SystemUser;
import com.yuanzong.wuliu.service.business.customer.factory.BusinessCustomerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class AdminBusinessCustomerBaodanService {

    public ApiResult page(AdminBusinessCustomerBaodanPageParam param) throws Exception {
        // ===================================================================================//
        // ===== 当前登陆用户
        // ===================================================================================//
        SystemUser runtimeUser = AdminHandlerInterceptorAdapter.getRuntimeUser();
        // ===================================================================================//
        // ===== 参数校验
        // ===================================================================================//
        if (param == null) {
            throw new BusinessException("参数为空");
        }
        // ===================================================================================//
        // ===== 业务执行
        // ===================================================================================//
        BusinessCustomerBaodanPageQuery businessCustomerBaodanPageQuery = new BusinessCustomerBaodanPageQuery();
        BeanUtils.copyProperties(param, businessCustomerBaodanPageQuery);
        ApiResultPage<BusinessCustomerBaodanPageByMapperBo> apiResultPage = BusinessCustomerFactory.getBusinessCustomerBaodanService().pageByMapper(businessCustomerBaodanPageQuery);
        return ApiResult.success(apiResultPage);
    }
}
